#ifndef VIEW_H
#define VIEW_H

#include "IAbstract_observer.h"
#include "aircraft_serializer.h"
#include <common/parameters.h>
#include "common/uav_texture.h"
#include "common/types.h"

#include <QObject>
#include <QVector>
#include <QCloseEvent>
#include <QBitArray>
#include <QTranslator>


class Model;
class Principal_window;
class Param_widget_uav;
class Param_widget_conventional;
class Main_dialog;
class Geometries_widget;
class Configuration_dialog;
class Settings_dialog;

class View : public QObject, public IAbstract_observer
{
    Q_OBJECT
public:
    explicit View(QObject *parent = 0);
    ~View();

signals:
    void s_new_project(const QString &project_name, const QString &module);
    void s_open_project(const QString &project_name, int module);
    void s_save_project();
    void s_load_parameters(ParametersWidget *parameters, Airfoils_curve_map *airfoil_point_list, int module);
    void s_load_configuration(int configuration);
    void s_draw_configuration(int configuration);
    void s_update_configuration(int configuration, void *values);
    void s_simulate(int configuration, configurations_parameters_uavs *p);
    void s_play_pause(int configuration);
    void s_rewind(int configuration);
    void s_add_simulation_zones_to_model(int configuration, QVector<time_zone *> zones);
private slots:
    void new_project();
    void new_project_module(int module);
    void load_parameters(ParametersWidget *parameters, Airfoils_curve_map *airfoil_point_list, int module);
    void open_project(const QString &project_name);
    void close_project(QCloseEvent *ev);
    void simulate_pressed(int configuration);
    void send_simulate_info(configurations_parameters_uavs *cpu);
    void send_draw_configuration(int configuration);
    void play_pause();
    void rewind();
    void settings();
    void set_spanish();
    void set_english();
    void graphic_geometry();
    void graphic_all_configurations();
public:
    Principal_window *get_principal_window();
    void set_model(Model *model);
    void on_update(const Configuration *config);
    void simulate_configuration(configurations_parameters_uavs *cpu, bool file_exist);
    void show_configs(QVector<Parameters *> values);
    Airfoils_curve_map *get_airfoils_list_point(QMap<QString, QString> airfoils);
    void clean_view();
    void enable_graphic_all_configuration();
private:
    bool ok_to_continue();
    void retranslateUIs();
private:
    Model *_model;
    Principal_window *_principal_window; // the principal windows
    Main_dialog *_main_dialog; // the wigdet to choose the configuration to create
    Geometries_widget *_geometries_widget; // the widget to show the configurations
    Param_widget_uav *_param_widget_uav; // the widget for the uav joined wings inputs
    Param_widget_conventional *_param_widget_conventional; // the widget for the conventional wings inputs
    Configuration_dialog *_configuration_dialog; // the configuration dialog for the simulation inputs
    Settings_dialog *_settings_dialog; // the setting dialog for the settings inputs
    Serializer *_serializer; // the serializer to write and read from datfiles
    int current_configuration; // the current drawn configuration
    QBitArray stored_configurations; // if the configurations are stored in disk
    QTranslator spanishTranslator; //Transtations for Spanish language
};

#endif // VIEW_H
